var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);

document.getElementById( 'ExportLineFrame' ).contentDocument.body.style.backgroundColor="#002760";
document.getElementById( 'ExportLineFrame' ).contentDocument.body.style.font="normal bold 13px Verdana";

formated_text = "";
formated_copy = "";

mytext = prefService.getCharPref( "extensions.Ultima.ClipboardExportLine" );

EL = 0;

var c0 = "<font color='#FFEECC'>";
var c1 = "<font color='#D0D0D0'>";
var c2 = "<font color='#E0FFFF'>";
var c3 = "<font color='#FFC0CB'>";

var Copyrights = "<br />"+c0+"[http://www.thedragonportal.eu Ultima v3.186]"+cc+"<br />"+"<br />"+c1+ "Server: "+cc+c2+"World of Legends (Age 66)"+cc;

if (( mytext.charAt(0) == "S")&&( mytext.charAt(1) == "T")) { EL = 1; Clipboard_Throne();    }
if (( mytext.charAt(0) == "S")&&( mytext.charAt(1) == "S")) { EL = 2; Clipboard_Science();   }
if (( mytext.charAt(0) == "S")&&( mytext.charAt(1) == "R")) { EL = 3; Clipboard_Buildings(); }
if (( mytext.charAt(0) == "S")&&( mytext.charAt(1) == "M")) { EL = 4; Clipboard_Military();  }

document.getElementById( 'ExportLineFrame' ).contentDocument.body.innerHTML = formated_text ;

textonly = textonly.replace(/<font color='#FFEECC'>/g, "");
textonly = textonly.replace(/<font color='#D0D0D0'>/g, "");
textonly = textonly.replace(/<font color='#E0FFFF'>/g, "");
textonly = textonly.replace(/<font color='#FFC0CB'>/g, "");

formated_copy = textonly;

if ( EL == 1 ) formated_copy += String.fromCharCode(13,10) + "** Export Line [ver 1] -- Throne [ver 1]: **" + String.fromCharCode(13,10) + Export_Line_Encryption(Export_Line);
if ( EL == 2 ) formated_copy += String.fromCharCode(13,10) + "** Export Line [ver 1] -- Science [ver 1]: **" + String.fromCharCode(13,10) + Export_Line_Encryption(Export_Line);
if ( EL == 3 ) formated_copy += String.fromCharCode(13,10) + "** Export Line [ver 1] -- Survey [ver 1]: **" + String.fromCharCode(13,10) + Export_Line_Encryption(Export_Line);
if ( EL == 4 ) formated_copy += String.fromCharCode(13,10) + "** Export Line [ver 1] -- Military [ver 1]: **" + String.fromCharCode(13,10) + Export_Line_Encryption(Export_Line);

Copy_To_Clipboard( formated_copy );

function Task_Manager() {
document.getElementById( 'ExportLineFrame' ).height=innerHeight ;
setTimeout("Task_Manager()",1);
}

Task_Manager();

function Copy_To_Clipboard(copytext) {

var str = null;
var trans = null;
var clip = null;
var clipid = null;

str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); 
if (!str) return false; 
 
str.data = copytext; 
 
trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable); 
if (!trans) return false; 
 
trans.addDataFlavor("text/unicode"); 
trans.setTransferData("text/unicode", str, copytext.length * 2); 
 
clipid = Components.interfaces.nsIClipboard; 
clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(clipid); 
if (!clip) return false; 
 
clip.setData(trans, null, clipid.kGlobalClipboard); 
copytext = null;
str = null;
trans = null;
clip = null;
clipid = null
return false;

}
